package com.xjy.system.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.xjy.common.utils.PageUtils;
import com.xjy.common.core.page.PagePlus;
import com.xjy.common.core.page.TableDataInfo;
import com.xjy.system.domain.bo.ReportLoanQueryBo;
import org.springframework.stereotype.Service;
import com.xjy.common.core.mybatisplus.core.ServicePlusImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xjy.system.domain.ReportLoan;
import com.xjy.system.mapper.ReportLoanMapper;
import com.xjy.system.domain.vo.ReportLoanVo;
import com.xjy.system.service.IReportLoanService;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Collection;

/**
 * ReportLoanService业务层处理
 *
 * @author zc
 * @date 2022-02-28
 */
@Service
public class ReportLoanServiceImpl extends ServicePlusImpl<ReportLoanMapper, ReportLoan> implements IReportLoanService {

	@Override
	public ReportLoanVo queryById(Long projId){
		return getVoById(projId, ReportLoanVo.class);
	}

	@Override
	public TableDataInfo<ReportLoanVo> queryPageList(ReportLoanQueryBo bo) {
		PagePlus<ReportLoan, ReportLoanVo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo), ReportLoanVo.class);
		return PageUtils.buildDataInfo(result);
	}

	@Override
	public List<ReportLoanVo> queryList(ReportLoanQueryBo bo) {
		return listVo(buildQueryWrapper(bo), ReportLoanVo.class);
	}

	private LambdaQueryWrapper<ReportLoan> buildQueryWrapper(ReportLoanQueryBo bo) {
		Map<String, Object> params = bo.getParams();
		LambdaQueryWrapper<ReportLoan> lqw = Wrappers.lambdaQuery();
		lqw.like(StrUtil.isNotBlank(bo.getProjName()), ReportLoan::getProjName, bo.getProjName());
		lqw.like(StrUtil.isNotBlank(bo.getBorrower()), ReportLoan::getBorrower, bo.getBorrower());
		return lqw;
	}
}
